<?php

class Logger {
    const LOG_PATH = './tmp/log.txt';

    public function log($xcaller, $message) {
        $data = "===== IP: " . $_SERVER['REMOTE_ADDR'] . ', Time: ' . date('d/m/Y H:i:s') . " =====\n";
        $data .= "Caller: " . $xcaller . "\n";
        $data .= print_r($message, true);
        $data .= "\n";
        if (file_exists(self::LOG_PATH) && is_writable(self::LOG_PATH)) {
            file_put_contents(self::LOG_PATH, $data, FILE_APPEND);
        }
    }
}
